package cn.com.homeyoda.aimate.aihealth.ui.bluetooth_guide;

import android.app.Application;

import androidx.annotation.NonNull;

import com.wzq.mvvmsmart.event.StateLiveData;

import java.util.ArrayList;

import cn.com.homeyoda.aimate.aihealth.base.BaseViewModel;
import cn.com.homeyoda.aimate.aihealth.bean.KePuBannerBean;
import cn.com.homeyoda.aimate.aihealth.data.Repository;

public class BluetoothGuideViewModel extends BaseViewModel<Repository> {

    public StateLiveData<ArrayList<KePuBannerBean>> bannerData;

    public BluetoothGuideViewModel(@NonNull Application application, Repository model) {
        super(application, model);
        bannerData = new StateLiveData<>();
    }

    public void getBanner() {

        ArrayList<KePuBannerBean> list = new ArrayList<>();
        KePuBannerBean banner = new KePuBannerBean("http://gips1.baidu.com/it/u=1567146704,1864816453&fm=3074&app=3074&f=PNG?w=2560&h=1440", "xxx");
        KePuBannerBean banner1 = new KePuBannerBean("http://cdn.pixabay.com/photo/2018/08/04/11/30/draw-3583548_1280.png", "yyy");
        list.add(banner);
        list.add(banner1);
        bannerData.postValueAndSuccess(list);
       /* model.getKePuBannerList()
                .compose(RxUtils.observableToMain())
                .compose(RxUtils.exceptionTransformer())
                .doOnSubscribe(ProtocolViewModel.this)
                .subscribe(new Observer<KePuBannerList>() {
                    @Override
                    public void onSubscribe(Disposable d) {
//                        stateIsShowData.postLoading();
                    }

                    @Override
                    public void onNext(KePuBannerList kePuBannerList) {
                        if (kePuBannerList.getCode() == 200) {

                            bannerData.postValueAndSuccess(kePuBannerList);
                        }
                    }


                    @Override
                    public void onError(Throwable e) {
                        KLog.e("进入onError" + e.getMessage());
                        Log.i("huahua", "stateLiveData.getMessage()=====" + e.getMessage());
                        Log.i("huahua", "e.getMessage()=====" + e.getMessage().toString());
                        // 关闭对话框
                        bannerData.postError();
                        if (e instanceof ResponseThrowable) {
                            ToastUtils.showShort(((ResponseThrowable) e).message);
                        }
                    }

                    @Override
                    public void onComplete() {
                        KLog.e("进入onComplete");
                        // 请求刷新完成收回
                        bannerData.postIdle();

                    }
                });*/
    }

}
